using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/**
 * 老窝脚本
 */
public class Heart : MonoBehaviour
{

    private SpriteRenderer sr;

    //爆炸特效的引用
    public GameObject explosionPrefab;

    //老窝爆炸的音效
    public AudioClip dieAudio;

    public Sprite BrokenSprite;


    // Start is called before the first frame update
    void Start()
    {
        sr = GetComponent<SpriteRenderer>();
    }



    public void Die(){
        sr.sprite = BrokenSprite;
        //调用爆炸特效
        Instantiate(explosionPrefab,transform.position,transform.rotation);

        PlayerMananger.Instance.isDefeat=true;
        //老窝死亡时播放声音
        AudioSource.PlayClipAtPoint(dieAudio,transform.position);
    }
}
